const { describe, it } = require("node:test");
const assert = require("node:assert");

const { notNullOrUndefined, isEmpty } = require("../lib/util.js");

describe("util.js", function () {
  it("notNullOrUndefined, value '0'", function () {
    assert.equal(notNullOrUndefined(0), true);
  });

  it("notNullOrUndefined, value 'null'", function () {
    assert.equal(notNullOrUndefined(null), false);
  });

  it("notNullOrUndefined, value 'undefined'", function () {
    assert.equal(notNullOrUndefined(undefined), false);
  });

  it("isEmpty, value '{}'", function () {
    assert.equal(isEmpty({}), true);
  });

  it("isEmpty, value 'null'", function () {
    assert.equal(isEmpty(null), true);
  });

  it("isEmpty, value 'undefined'", function () {
    assert.equal(isEmpty(undefined), true);
  });

  it("isEmpty, value 'NaN'", function () {
    assert.equal(isEmpty(NaN), false);
  });

  it("isEmpty, value 'Object'", function () {
    assert.equal(isEmpty(new Object({ key: "value" })), false);
  });

  it("isEmpty, value '0'", function () {
    assert.equal(isEmpty(0), false);
  });

  it("isEmpty, value ''", function () {
    assert.equal(isEmpty(""), true);
  });

  it("isEmpty, value 'asd'", function () {
    assert.equal(isEmpty("asd"), false);
  });
});
